﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：
    //

    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
    // 审核时间：
    // 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.Model.Enum;

namespace HZ.DrugTrade.Web.Hospitals.Procurement
{
    public partial class HospitalLoginPriceGoodsNo:BasePage
    {


        IBLL_HospitalLoginPriceGoods ih = Factory.BLL_HospitalLoginPriceGoods();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
             SetBind();
            }
        }
        /// <summary>
        ///  验证是输入
        /// </summary>
        public void YanZheng()
        {
            
        }

        /// <summary>
        /// 绑定符合条件的采购明细
        /// </summary>
        private void SetBind()
        {
            int totalCount;
            IList<Model.View.HospitalLoginPriceGoods> purchaseOrderDetailList = ih.GetHospitalLoginPriceGoods(GetCondition(), AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            AspNetPager1.RecordCount = totalCount;
            gvwNoConfirm.PageSize = AspNetPager1.PageSize;
            gvwNoConfirm.DataSource = purchaseOrderDetailList;
            gvwNoConfirm.DataBind();
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            SetBind();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            SetBind();
        }

 
        /// <summary>
        /// 导出2009-11-25
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExport_Click(object sender, EventArgs e)
        {
            int totalCount = 0;
            IList<Model.View.HospitalLoginPriceGoods> purchaseOrderDetailList = ih.GetHospitalLoginPriceGoods(GetCondition(), 1, 0, out totalCount);
            DataTable dt = HZ.Data.ModelConvert.GetDataTableFromModel(purchaseOrderDetailList);
            HZ.Excel.ExcelHelper.ExportDataForWeb(dt, gvwNoConfirm);
        }

        protected void gvwNoConfirm_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblgoodsID = e.Row.FindControl("lblGoodsID") as Label;//流水号
                HiddenField hidPrice = e.Row.FindControl("hidPrice") as HiddenField;//医疗机构价格
                HiddenField hidCount = e.Row.FindControl("hiCount") as HiddenField;//医疗机构购买数量
                //    Label lblshowPrice = e.Row.FindControl("showMessage") as Label;//流水号\
               
               
                //10为填写购买价格
                e.Row.Cells[10].Text = "<input style=\"width:60px\"autocomplete=\"off\" type=\"text\" id=\"txtPrice" + lblgoodsID.Text + "\" value=\"" + hidPrice.Value + "\" />";
           
              


               
                //11为填写购买数量
                e.Row.Cells[11].Text = "<input style=\"width:60px\"autocomplete=\"off\" type=\"text\" id=\"countProduces" + lblgoodsID.Text + "\" value=\"" + hidCount.Value + "\" />";
               


                //12为保存数据
                //e.Row.Cells[12].Text = "<input type=\"button\" id=\"btn" + lblgoodsID.Text + "\" value=\"保存\" />";
                e.Row.Cells[12].Text = "<input type=\"button\" id=\"btn" + lblgoodsID.Text + "\"  value=\"保存\" onClick=\"SavePrice('txtPrice" + lblgoodsID.Text + "', '" + lblgoodsID.Text + "', '" + CurrentAccount.GetUser().UserID + "', 'countProduces" + lblgoodsID.Text + "')\"/>";
               

            }
        }
        /// <summary>
        /// 获取查询条件
        /// </summary>
        /// <returns></returns>
        private Model.Query.HospitalLoginPriceGoods GetCondition()
        {
            Model.Query.HospitalLoginPriceGoods where = new HZ.DrugTrade.Model.Query.HospitalLoginPriceGoods();
            where.GoodsID = txtGoodsID.Text.Trim();//流水号
            where.GoodsName = txtGoodsName.Text.Trim();//产品名称
            where.Material = txtMaterial.Text.Trim();//材质
            where.Outlookc = txtOutLook.Text.Trim();
            where.CompanyName_SC = txtCompanyName_Sc.Text.Trim();//生产企
            where.Append = " GoodsId not in(select GoodsId from TB_HospitalLoginPrice where HospitalID='" + CurrentAccount.GetUser().UserID + " ' and NVL(price,0)<>0 )";//未填写

            return where;
        }
       

    }
}
